using System.ComponentModel.DataAnnotations.Schema;
using System.Data.Entity.ModelConfiguration;

namespace ConsoleApplication2.Models.Mapping
{
    public class CompanyMap : EntityTypeConfiguration<Company>
    {
        public CompanyMap()
        {
            // Primary Key
            this.HasKey(t => t.ID);

            // Properties
            this.Property(t => t.CompID)
                .IsRequired()
                .HasMaxLength(15);

            this.Property(t => t.CompName)
                .IsRequired()
                .HasMaxLength(50);

            this.Property(t => t.database)
                .IsRequired()
                .HasMaxLength(50);

            this.Property(t => t.Server)
                .IsRequired()
                .HasMaxLength(20);

            this.Property(t => t.ODBC_DSN)
                .IsRequired()
                .HasMaxLength(15);

            this.Property(t => t.File_Primary_Key)
                .HasMaxLength(10);

            // Table & Column Mappings
            this.ToTable("Company");
            this.Property(t => t.ID).HasColumnName("ID");
            this.Property(t => t.CompID).HasColumnName("CompID");
            this.Property(t => t.CompName).HasColumnName("CompName");
            this.Property(t => t.database).HasColumnName("database");
            this.Property(t => t.Server).HasColumnName("Server");
            this.Property(t => t.Project).HasColumnName("Project");
            this.Property(t => t.ODBC_DSN).HasColumnName("ODBC_DSN");
            this.Property(t => t.YEAR).HasColumnName("YEAR");
            this.Property(t => t.File_Primary_Key).HasColumnName("File Primary Key");
        }
    }
}
